﻿Imports DTO
Imports System.Linq

Public Class HocKyDAO
    Public Function getHocKy_DAO()
        Dim list As List(Of HocKyDTO) = New List(Of HocKyDTO)

        Dim context As DataproviderDataContext = New DataproviderDataContext()

        Dim listHocKy = From HocKy In context.HocKies
                        Select HocKy
        For Each value As HocKy In listHocKy
            Dim entity As HocKyDTO = New HocKyDTO()
            entity.MaHK = value.MaHK
            entity.HocKy = value.HocKy
            entity.NamHoc = value.NamHoc

            list.Add(entity)
        Next
        Return list
    End Function

    Public Function getYear_DAO()
        Dim listyear As List(Of HocKyDTO) = New List(Of HocKyDTO)

        Dim context As DataproviderDataContext = New DataproviderDataContext()

        Dim list = (From hocky In context.HocKies
                    Select hocky.NamHoc).Distinct()

        For Each value In list
            Dim entity As HocKyDTO = New HocKyDTO()
            entity.NamHoc = value

            listyear.Add(entity)
        Next
            Return listyear
    End Function

End Class
